extends Resource
class_name  CityEntity

var city_id:int
var city_name:String
var population_value:int
var gold_value:int
var food_value:int
var farm_value:int
var business_value:int
# 民忠
var people_happiness_value:int
# 灾难抵抗能力
var disaster_stop_value:int
var near_cities:Array[CityEntity]

var hero_count:int:
	get:
		return hero_list.size()

#region 容纳的对象
# 武将列表
var hero_list:Array[HeroEntity]
# 所属阵营
var faction_id:int
# 太守
var standholder_id:int
#endregion

var city_position:Vector2

var total_soliders:int:
	get:
		return hero_list.reduce(func (prev:int,h:HeroEntity): return prev + h.underling_value , 0)
		
func get_king()->HeroEntity:
	var faction = GameDataUtility.get_faction_by_id(faction_id)
	if faction == null:
		return null
	return faction.get_king()
	pass

func get_standholder()->HeroEntity:
	for h in hero_list:
		if h.hero_id == standholder_id:
			return h
		pass
	return null
	pass
